<template>
  <div class="demo">
    <template>
      <div v-if="mode === 'edit'">
        <button @click="mouseover">提示</button>
      </div>
      <div v-else>{{ value }}</div>
    </template>
  </div>
</template>

<script>
import Vue from "vue";
import { Toast } from "vant";
Vue.use(Toast);
export default {
  name: "toast",
  components: {},
  props: {
    value: {},
    mode: {
      default: "edit", // 编辑模式和 edit， 展示模式 view
    },
    readonly: {
      type: Boolean,
      default: false,
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    tipMsg: {
      default: "",
    },
  },
  data() {
    return {};
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
    if(this.value){
      this.tipMsg = this.value;
      if(this.mode == 'view'){
          this.disabled = true;
      }
    }
  },
  methods: {
    mouseover() {
      Toast(this.tipMsg);
      this.$emit("input", this.tipMsg);
    },
  },
};
</script>
<style lang="scss" scoped>
.demo {
  width: 100%;
  .van-cell {
    padding: 0;
  }
}
</style>
